package com.bestsoft.web.controller.baseinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestsoft.common.annotation.Log;
import com.bestsoft.common.core.controller.BaseController;
import com.bestsoft.common.core.domain.AjaxResult;
import com.bestsoft.common.enums.BusinessType;
import com.bestsoft.baseinfo.domain.BaseInfoSupply;
import com.bestsoft.baseinfo.service.IBaseInfoSupplyService;
import com.bestsoft.common.utils.poi.ExcelUtil;
import com.bestsoft.common.core.page.TableDataInfo;

/**
 * 供应商资料Controller
 * 
 * @author1 王识宇
 * @date 2023-09-19
 */
@RestController
@RequestMapping("/domain/supply")
public class BaseInfoSupplyController extends BaseController
{
    @Autowired
    private IBaseInfoSupplyService baseInfoSupplyDocService;

    /**
     * 查询供应商资料列表
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseInfoSupply baseInfoSupplyDoc)
    {
        startPage();
        List<BaseInfoSupply> list = baseInfoSupplyDocService.selectBaseInfoSupplyDocList(baseInfoSupplyDoc);
        return getDataTable(list);
    }

    /**
     * 导出供应商资料列表
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:export')")
    @Log(title = "供应商资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseInfoSupply baseInfoSupplyDoc)
    {
        List<BaseInfoSupply> list = baseInfoSupplyDocService.selectBaseInfoSupplyDocList(baseInfoSupplyDoc);
        ExcelUtil<BaseInfoSupply> util = new ExcelUtil<BaseInfoSupply>(BaseInfoSupply.class);
        util.exportExcel(response, list, "供应商资料数据");
    }

    /**
     * 获取供应商资料详细信息
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:query')")
    @GetMapping(value = "/{supplyid}")
    public AjaxResult getInfo(@PathVariable("supplyid") Long supplyid)
    {
        return success(baseInfoSupplyDocService.selectBaseInfoSupplyDocBySupplyid(supplyid));
    }

    /**
     * 新增供应商资料
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:add')")
    @Log(title = "供应商资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseInfoSupply baseInfoSupplyDoc)
    {
        return toAjax(baseInfoSupplyDocService.insertBaseInfoSupplyDoc(baseInfoSupplyDoc));
    }

    /**
     * 修改供应商资料
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:edit')")
    @Log(title = "供应商资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseInfoSupply baseInfoSupplyDoc)
    {
        return toAjax(baseInfoSupplyDocService.updateBaseInfoSupplyDoc(baseInfoSupplyDoc));
    }

    /**
     * 删除供应商资料
     */
    @PreAuthorize("@ss.hasPermi('domain:supply:remove')")
    @Log(title = "供应商资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplyids}")
    public AjaxResult remove(@PathVariable Long[] supplyids)
    {
        return toAjax(baseInfoSupplyDocService.deleteBaseInfoSupplyDocBySupplyids(supplyids));
    }
}
